package org.yray;

import java.io.IOException;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;

public class HttpStringFinder {
    public static void main(String[] args) {
        Path startingDir = Paths.get("D:\\project\\apollo_config_export_2024_0313_11_44_24"); // 替换为你的起始目录
        try (Stream<Path> paths = Files.walk(startingDir)) {
            paths
                    .filter(Files::isRegularFile) // 只保留普通文件，过滤掉目录
                    .forEach(path -> {
                        try {
                            List<String> lines = Files.readAllLines(path);
                            for (String line : lines) {
                                    int begin=0;
                                    int httpIndex = line.indexOf("http:");
                                    while (httpIndex>=begin) {
                                        int lastIndex = line.indexOf("\"", httpIndex);
                                        if (httpIndex != -1 && lastIndex <= line.length()) {
                                            String substring = line.substring(httpIndex, lastIndex);
                                            if(substring.contains("eureka")) {
                                                System.out.println("File: " + path + ", Substring: " + substring);
                                            }
                                        }
                                        begin=lastIndex;
                                        httpIndex=line.indexOf("http:",lastIndex);
                                    }

                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}